package com.hruiworks.campusgroup.schedule;

import com.hruiworks.campusgroup.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 统一管理定时任务
 */
@Slf4j
@Service
public class ScheduleService {

    @Resource
    private ActivityService activityService;

    @Async("mainTask")
    @Scheduled(cron = "0 0 2 * * ?")
    public void updateActivityGrade() {
        Boolean result = activityService.updateActivityGrade();
        if (BooleanUtils.isTrue(result)) {
            log.info("更新活动分数成功");
        } else {
            log.info("更新活动分数失败");
        }
    }

}
